﻿'RecFinder v1.0
'A Simple App for Interacting and Searching through databases
'Project Leader and Contributor = Alagkiozidis Eleftherios
'Project Member and Revision Commiter = Tsiokas Evaggelos
'Project Member and Revision Commiter = Isaia Xasapi
'Project Member and Revision Commiter = Xatzigianni Dora
'Overall Project Supervisor = Michalis Salampasis
'------------------------------------------------------------
Imports System.IO
Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports System.Data.Common

Public Class Main

    Private Sub SapliaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SapliaToolStripMenuItem.Click

    End Sub

    Private Sub ExitRecFinderToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitRecFinderToolStripMenuItem.Click
        'This submenu terminates the Application RecFinder

    End Sub

    Private Sub AboutRecFinderToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutRecFinderToolStripMenuItem.Click
        'This SubMenu is responsible for showing user information About Recfinder (Application Builders etc.)
        MsgBox("RecFinder v1.0 - A Simple Yet Powerfull Database Seaching tool")
    End Sub

    Private Sub DataBaseConn() 'This function will perform database connection
        Dim statement As String
        statement = "select * from movies"    'This is a variable that stores a sql Statement (final edition will have textbox for user defined statements"
        Dim filepath As String = "c:\movies.mdb" 'This variable stores the database file path 
        Dim conn As New OleDbConnection       'This will be used to connect to db
        conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filepath 'The connectionstring through the database file

        Try

            Using adapter As New OleDbDataAdapter(statement, conn.ConnectionString) 'This adapter will be used for the interaction with Database
                Dim dst As New DataSet  'This dataset will do most of the job
                adapter.Fill(dst, "movies") 'Dataset fills with the table we give
                MainView.DataSource = dst.Tables("movies")  'The Datagrid takes the table and shows it

                For Each dcol As DataColumn In dst.Tables("movies").Columns 'This For-Each Loop fills the combobox(es)
                    cmbfilter1.Items.Add(dcol.ToString)

                Next dcol

            End Using

            btnsearch.Enabled = True 'When the connection is done , the search button activates

        Catch ex As Exception 'This is in case something goes wrong
            MsgBox(ex.Message)
        End Try





    End Sub

    Private Sub btnconn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnconn.Click
        DataBaseConn()
    End Sub

    Private Sub btnsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
        'This Button will perform a search through the database based on user's selection over the combo-boxes above
        'It will be activated as soon as the user connects properly to the database otherwise it will not be activated
        'When a user selects an item from the Comboboxes which represents a Column from the Database table, a textbox below
        'will be used for typing a search term -  for example user selects "Genre" and user types "Action" so the button
        'will search the database with this criteria to show only records with type Action
    End Sub
End Class
